"! Info:
Abstract base class for collection classes. A collection contains a number of elements and provides various operations on those elements.

Instances of Collection should not be created directly. Rather, one of the subclasses such as Array or Dictionary should be used.
Examples:

"
Magnitude subclass: Collection [
<category: 'Library-Collections'>
"! Info:
Check if this collection is smaller than an another collection. Compares the collections one element at a time, and returns true on first instance of a smaller element.
Examples:

"
< aCollection [
self do: [ :elt | 
	(aCollection includes: elt) ifFalse: [ 
		^ false 
	] 
].
^ true
]

"! Info:
Check if this collection is equal to another collection
Examples:

"
= aCollection [
(aCollection isKindOf: Collection) ifTrue: [
	^ self < aCollection and: [ 
		aCollection < self 
	] 
].
^ false.
]

"! Info:
Return a new array containing all the elements from this collection
Examples:

"
asArray [
| newArray i |
newArray := Array new: self size.
i := 1.
self do: [ :elt | 
	newArray at: i put: elt.
	i := i + 1 
].
^ newArray
]

"! Info:
Return a new string containing all the elements from this collection
Examples:

"
asString [
| ret i |
ret := String new: self size.
i := 1.
self do: [ :elt | 
	ret at: i put: elt.
	i := i + 1
].
^ ret
]

"! Info:
Return the element at a specified index, and raise an exception if it doesn't exist.
Examples:

"
at: value [
^ self at: value ifAbsent: [ 
	self noElement 
]
]

"! Info:
Return the element at a specified index, and execute the aBlock if it doesn't exist
Examples:

"
at: value ifAbsent: aBlock [
self do: [ :elt | 
	elt = value ifTrue: [ 
		^ elt
	]
].
^ aBlock value
]

"! Info:
Return a new collection of the same size as the receiver. Each element in the new collection is the value of the element at the in its position in the receiver, but transformed by transformBlock.
Examples:
\"multiply array elements by 2\"
#(1 2 3 4) collect: [ :n |
	n*2.
].
"
collect: transformBlock [
| ret i |
ret := Array new: self size.
i := 1.
self do: [:elt |
	ret at: i put: (transformBlock value: elt).
	i := i + 1
].
^ ret
]

"! Info:

Examples:
"
do: aBlock [
self subclassResponsibility
]

"! Info:
Return a new Array that includes all the elements from argLow from the receiver.
Examples:

"
from: argLow [
^ self from: argLow to: (self size)
]

"! Info:
Return a new Array that includes all the elements from argLow to argHigh from the receiver.
Examples:

"
from: argLow to: argHigh [
| ret i size base low high |
low := argLow max: 1.
high := argHigh min: self size.
size := (high - low) + 1.
(size < 1) ifTrue: [ 
	^ Array new: 0 
].
ret := Array new: size.
base := i := 1.
self do: [ :elt |
	((i >= low) and: [i <= high]) ifTrue: [
		ret at: base put: elt.
		base := base + 1.
		(base > size) ifTrue: [ 
			^ ret 
		]
	].
	i := i + 1.
].
^ ret
]

"! Info:
Returns true if this collection contains the object value
Examples:
"
includes: value [
self at: value ifAbsent: [ 
	^ false 
].
^ true
]

"! Info:
Return true if there are no elements in this collection

Examples:
"
isEmpty [
^ self size = 0
]

"! Info:
raise an \"element not found\" exception.
Examples:

"
noElement [
self error: #sysNoElt
]

"! Info:
Return the number of elements in this collection

Examples:
"
size [
| count |
count := 0.
self do: [ :i | 
	count := count + 1
].
^ count
]

]

"! "
MetaMagnitude subclass: MetaCollection [
<category: 'Library-Collections'>
]

